package com.zzb.framework.query;

import java.util.HashMap;

/**
 * 灵活分页配置
 */
public final class FlexiblePageSearchForm extends HashMap<String,Object> implements IPageSearchForm{

    public String getAdditionalCondition() {
        return getOrDefault("additionalCondition","").toString();
    }


    public Integer getPageSize() {
        return Integer.valueOf(getOrDefault("pageSize","10").toString());
    }


    public Integer getPage() {
        return Integer.valueOf(getOrDefault("page","1").toString());
    }


    public String getOrderBy() {
        return getOrDefault("orderBy","").toString();
    }

    public Integer getStartOffset() {
        int startOffset = 0;
        if(getPage() > 0)
            startOffset = (getPage()-1) * getPageSize();
        return startOffset;
    }
}
